﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;
using System.Drawing;

namespace Huirui.Cavan.Application.MainBoundedContext.AttachmentModule
{
    [ServiceContract(Namespace = "http://Huirui.Cavan.FileService")]
    public interface IFileUploadAppService 
    {
        [OperationContract]
        void UploadFile(FileUploadRequest request);

        [OperationContract]
        void CopyFile(string directory, string fileName, string prefix);

        [OperationContract]
        string GetDirectory(int attachmentGroupID);

        [OperationContract]
        string GetNewFileName(int originalWidth, int originalHeight, string fileSuffix);

        [OperationContract]
        string GetFileSuffix(string fileName);

        [OperationContract]
        string GetRestrictFileSuffix(int attachmentGroupID);

        [OperationContract]
        string GetSaveFileSuffix(int attachmentGroupID);

        [OperationContract]
        long GetRestrictFileLength(int attachmentGroupID);

        [OperationContract]
        string GetRestrictFormate(int attachmentGroupID);

        [OperationContract]
        int GetRestrictFileCount(int attachmentGroupID);

        [OperationContract]
        void CutPhoto(int attachmentGroupID, string directory, string oldFileName, string newFileName, int partWidth, int partHeight, int origStartPointX, int origStartPointY);

        void DeleteFile(string directory, string fileName);
    }

    [MessageContract]
    public class FileUploadRequest
    {
        [MessageHeader(MustUnderstand = true)]
        public int AttachmentGroupID;

        [MessageHeader(MustUnderstand = true)]
        public string FileDirectory;

        [MessageHeader(MustUnderstand = true)]
        public bool WaterMark;

        [MessageHeader(MustUnderstand = true)]
        public string FileName;

        [MessageBodyMember(Order = 1)]
        public Stream FileData;

    }

    [MessageContract]
    public class FileDeleteRequest
    {
        [MessageHeader(MustUnderstand = true)]
        public int AttachmentGroupID;

        [MessageHeader(MustUnderstand = true)]
        public string FileDirectory;

        [MessageHeader(MustUnderstand = true)]
        public string FileName;
    }
}
